/*!
public customed js code.
 */
 function resizeJqGrid(tgrid){
	// alert("into resize.");
	container = tgrid.parents('.pageContent:first');
	var cw = container.width();
	var ch = container.height();
	var ph = container.find(".ui-jqgrid-pager").height();
	var th = container.find(".ui-jqgrid-titlebar").height();
	var hh = container.find(".ui-jqgrid-hdiv").height();
	// alert(th);
	if (th > 5)
		th = th + 8;
	tgrid.jqGrid('setGridWidth', cw - 2, 'true');
	tgrid.jqGrid('setGridHeight', ch - ph - th - hh-30, 'true');
}	           
	           
var gridResize = function(){
	//alert(1);
	jQuery('.unitBox:visible').each(function(){
		//alert(2);
				
			jQuery(this).find('.ui-jqgrid-btable:visible').each(function(){
				//alert(3);
				var tableId = jQuery(this).attr("id");
				tgrid = $("#"+tableId);
				resizeJqGrid(tgrid);
			});
		//});
	});
};

/*  jQuery(window).unbind("gridResize").bind("gridResize",gridResize); 
jQuery(window).resize(function() {
	jQuery(window).trigger("gridResize");
}); */
 jQuery(window).unbind(DWZ.eventType.resizeGrid).bind(DWZ.eventType.resizeGrid,gridResize);
jQuery(window).resize(function() {
	jQuery(window).trigger(DWZ.eventType.resizeGrid);
}); 

function ajaxCallBack(json) {
	DWZ.ajaxDone(json);
	if (json.ajaxStatus == "error") {
		alertMsg.error(json.ajaxMessage);
	} else {
		// alert(json.ajaxMessage);
		try {
			navTab.reload();
			// $.pdialog.closeCurrent();
		} catch (e) {
			alert(e.message);
		}
		alertMsg.correct(json.ajaxMessage)
	}

}
function popAjaxCallBack(json) {
	DWZ.ajaxDone(json);
	if (json.ajaxStatus == "error") {
		alertMsg.error(json.ajaxMessage);
	} else {
		// alert(json.ajaxMessage);
		try {
			navTab.reload();
			$.pdialog.closeCurrent();
		} catch (e) {
			alert(e.message);
		}
		alertMsg.correct(json.ajaxMessage)
	}

}

function processGridSelectedRecords(jqGridId, url, msg) {
	var sid = jQuery("#" + jqGridId).jqGrid('getGridParam', 'selarrrow');
	var eurl = url + "?ids=" + sid;
	eurl = encodeURI(eurl);
	// alert(url);
	if (sid == null || sid.length == 0) {
		alertMsg.warn("请至少选择一条记录.");
		return;
	} else {
		alertMsg.confirm(msg, {
			okCall : function() {
				jQuery.post(eurl, {}, function(json) {
					DWZ.ajaxDone(json);
					if (json.ajaxStatus == "error") {
						alertMsg.error(json.ajaxMessage);
					} else {
						// alert(json.ajaxMessage);
						try {
							navTab.reload();
						} catch (e) {
							alert(e.message);
						}
						alertMsg.correct(json.ajaxMessage)
					}

				}, "json");

			}
		});
	}
}

